package com.hu.zhcc.shiro.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.shiro.dao.CheckItemDAO;
import com.hu.zhcc.shiro.entity.bo.CheckItem;
import com.hu.zhcc.shiro.entity.vo.CheckItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 检查项服务
 */
@Service("checkItemService")
public class CheckItemServiceImpl implements CheckItemService {
    @Autowired
    private CheckItemDAO checkItemDAO;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return checkItemDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(CheckItem record) {
        return checkItemDAO.insert(record);
    }

    @Override
    public int insertSelective(CheckItem record) {
        return checkItemDAO.insertSelective(record);
    }

    @Override
    public CheckItem selectByPrimaryKey(Integer id) {
        return checkItemDAO.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(CheckItem record) {
        return checkItemDAO.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(CheckItem record) {
        return checkItemDAO.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<CheckItem> selectByCondition(CheckItemVO checkItemVO) {
        PageHelper.startPage(checkItemVO.getPageNum(),checkItemVO.getPageSize());
        List<CheckItem> checkItems = checkItemDAO.selectByCondition(checkItemVO.getQueryString());
        PageInfo<CheckItem> checkItemPageInfo = new PageInfo<>(checkItems);
        return checkItemPageInfo;
    }

    @Override
    public List<CheckItem> findAll() {
        return checkItemDAO.selectByCondition(null);
    }

    @Override
    public List<CheckItem> selectByCheckGroupId(Integer id) {
        return checkItemDAO.selectByCheckGroupId(id);
    }

}
